<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>登录</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" href="../css/login.css">

    <!-- jquery -->
    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <!-- bootstrap -->
    <link rel="stylesheet" type="text/css" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
    <script type="text/javascript" th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
    <!-- jquery-validator -->
    <script type="text/javascript" th:src="@{/jquery-validation/jquery.validate.min.js}"></script>
    <script type="text/javascript" th:src="@{/jquery-validation/localization/messages_zh.min.js}"></script>
    <!-- layer -->
    <script type="text/javascript" th:src="@{/layer/layer.js}"></script>
    <!-- md5.js -->
    <script type="text/javascript" th:src="@{/js/md5.min.js}"></script>
    <!-- common.js -->
    <script type="text/javascript" th:src="@{/js/common.js}"></script>

</head>
<body>

<form name="loginForm" id="loginForm" method="post" style="width:50%; margin:0 auto">

    <div id="bigBox">
        <h1>LOGIN</h1>
        <div class="inputBox">
            <div class="inputText">
                <span class="iconfont icon-nickname"></span>
                <input type="text" placeholder="Username" id="userName"/>
            </div>
            <div class="inputText">
                <span class="iconfont icon-visible"></span>
                <input type="password" placeholder="Password" id="password"/>
            </div>
        </div>
        <input class="loginButton" type="button" value="Login" th:onclick="login()"/>
    </div>


</form>
</body>
<script>

    function login() {
//        加载中
        g_showLoading();
        var inputPass = $("#password").val();
        var salt = g_passsword_salt;
        var str = "" + salt.charAt(0) + salt.charAt(2) + inputPass + salt.charAt(5) + salt.charAt(4);
        var password = md5(str);
        $.ajax({
            url: "/login/do_login",
            type: "POST",
            data: {
                userName: $("#userName").val(),
                password: password
            },
            success: function (data) {
                layer.closeAll();
                if (data.status == 200) {
                    layer.msg("成功");
                    window.location.href = "/index.html";
                } else {
                    layer.msg(data.msg);
                }
            },
            error: function () {
                layer.closeAll();
            }
        });
    }
</script>
</html>